Attribute VB_Name = "ModFunctions"
Option Explicit

'---------------------------------------------------------------------------------------
' Procedure : IsAnySelectedItem
' Date      : 28/10/2011
' Purpose   : Kiem tra xem listview co item nao duoc lua chon hay khong
'---------------------------------------------------------------------------------------
Public Function IsAnySelectedItem(ByVal lstView As ListView) As Boolean
    Dim item As ListItem
    IsAnySelectedItem = False
    For Each item In lstView.ListItems
        If item.Selected = True Then
            IsAnySelectedItem = True
            Exit Function
        End If
    Next
End Function

'---------------------------------------------------------------------------------------
' Procedure : ClearSelection
' Date      : 28/10/2011
' Purpose   : Mac dinh khong select bat cu item nao trong listview
'---------------------------------------------------------------------------------------
Public Sub ClearSelection(ByRef lstView As ListView)
    Dim item As ListItem
    For Each item In lstView.ListItems
        item.Selected = False
    Next
End Sub

'---------------------------------------------------------------------------------------
' Procedure : OpenXML
' Date      : 28/10/2011
' Purpose   : Mo file xml
'---------------------------------------------------------------------------------------
Public Function OpenXML(ByVal FileName As String) As DOMDocument
    Dim xmlDoc As DOMDocument
    
    Set xmlDoc = New DOMDocument
    xmlDoc.validateOnParse = True
    xmlDoc.preserveWhiteSpace = True
    xmlDoc.Load (FileName)
    If Not xmlDoc.parseError Is Nothing Then
        If xmlDoc.parseError.errorCode <> 0 Then
            Err.Raise 457, "Validate Configuration file", "Error while load file '" & FileName & "' Error " & xmlDoc.parseError.errorCode & " - " & xmlDoc.parseError.srcText
            Set xmlDoc = Nothing
        End If
    End If
    
    Set OpenXML = xmlDoc
End Function

'---------------------------------------------------------------------------------------
' Procedure : GetReport
' Date      : 28/10/2011
' Purpose   : Lay report (noi dung message) dua vao Name va Area
'---------------------------------------------------------------------------------------
Public Function GetReport(Name As String, Area As String) As String
    Dim vInfoSpec As clsInfoSpecific
    GetReport = ""
    For Each vInfoSpec In g_colInfoSpecific
        If UCase(Trim(vInfoSpec.Name)) = UCase(Trim(Name)) And UCase(Trim(vInfoSpec.Area)) = UCase(Trim(Area)) Then
            GetReport = vInfoSpec.Report
            Exit Function
        End If
    Next vInfoSpec
End Function
